<?php
/* OpenBIBLIO -- A library administration web interface
 * Copyright (C) 2002-2005 Fr&eacute;d&eacute;ric Descamps <lefred@tiscali.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

if ($_POST['id']) $id = $_POST['id'];
else $id	= $_GET['id']; 
$sw		= $_POST['sw'];
$pwd_root	= $_POST['pwd_root'];

if(!$id)
{
        $requete = "select * from admin";
        if(!($resultat = biblio_db_query($requete)))
        { print "PROBLEME : " .biblio_db_error(); }
        else 
        {
                echo "<CENTER><H3>";
		echo _("Effacer un administrateur");
		echo "</H3>";
                echo "<TABLE><TR><th>Administrateur</th><th>Action</th>";
        
                while ($row = biblio_db_fetch_array($resultat)) 
	        {      
                        $admin_id = $row['id'];           
                        $admin_nom =  $row['login'];                                
                        echo "<TR><TD>$admin_nom</TD><TD><A href=\"admin.php?action=del&type=admin&id=$admin_id\">";
			echo _("effacer");
			echo "</A></TD>";            
                }
                echo "</TABLE></CENTER>";
        }
}
else
{

    if ($sw!=1)
    {
        ?>
        <CENTER><H3>
	<?php echo _("Effacer un administrateur"); ?>
	</H3>
        <FORM action=admin.php METHOD=POST>
        <TABLE BORDER=0>
        <TR>
        <TD>
	<?php echo _("Mot de passe SuperUtilisateur"); ?>
	:</TD><TD><INPUT TYPE="password" NAME="pwd_root" size = 10></TD>
        </TABLE><BR>
        <INPUT TYPE="hidden" NAME="user" value="<?php echo $user; ?>">
        <INPUT TYPE="hidden" NAME="action" value="<?php echo $action; ?>">
        <INPUT TYPE="hidden" NAME="type" value="<?php echo $type; ?>">
        <INPUT TYPE="hidden" NAME="sw" value="1">
        <INPUT TYPE="hidden" NAME="id" value="<?php echo $id; ?>">        
        <input type="Submit" value="
	<?php echo _("Connexion"); ?>
	">
        </FORM>
        </CENTER>
        <?php
    }   
    else
    {      
        if(md5($pwd_root) != get_rootpwd() )        
        {
         echo "<CENTER><BR>";
	 echo _("Le mot de passe du superuser n'est pas valide, recommencez!");
	 echo "<BR><BR>";
         echo "<A href=\"admin.php?action=del&type=admin&id=$admin_id\">";
	 echo _("retour");
	 echo "</A></CENTER>";
	 include("includes/footer.inc");
         exit;
        }
      
      
      $requete = "delete from admin where id=$id";
      if(!($resultat = biblio_db_query($requete)))
      { echo "PROBLEME : " .biblio_db_error(); exit;}  
      put_log(4,$requete,$user);
      echo "<CENTER><BR>";
      echo _("Cet administrateur a &eacute;t&eacute; &eacute;ffac&eacute;.");
      echo "<br></center>";
    } 
}
?>
<br><br>
<div>
<span id=left-text>
<A HREF="admin.php?menu=1">
<?php echo _("retour menu administration"); ?>
</A><BR>
<A HREF="index.php">
<?php echo _("retour menu principal"); ?>
</A></span>
</div>
<br>
